import axios from 'axios';
import { Message } from 'element-ui';
import { param } from 'jquery';


const service = axios.create({
    baseURL: "/api",
    timeout: 5000
})

service.interceptors.request.use(conf => {
    return conf
})
service.interceptors.response.use(conf => {
    return conf.data
}, err => {
    Message({
        message: err.response.data.message,
        type: 'error'
    });
    return { code: err.response.data.code, message: err.response.data.message }
})

export function xiname(params) {
    return service({
        url: "/admin/department/names",
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function dlyz() {
    return service({
        url: "user/login/status",
        method: "get",
        // post传递参数 -- data
    
    })
};

///1
export function userLogin(data) {
    return service({
        url: "user/login",
        method: "post",
        // post传递参数 -- data
        data: data
    })
};

////2
export function xilei(params, page = 1) {
    return service({
        url: "/admin/department/page/" + page,
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function xilei1(params) {
    return service({
        url: "/admin/major/page/count" ,
        method: "get",
        // get传递参数 -- params
        params: params
    })
};

export function xileijia(data) {
    return service({
        url: "/admin/department" ,
        method: "post",
        // get传递参数 -- params
       data:data
    })
};
export function xileixq(id) {
    return service({
        url: "/admin/department/"+id ,
        method: "get",
        // get传递参数 -- params
     
    })
};
export function xileixg(data) {
    return service({
        url: "/admin/department",
        method: "put",
        // get传递参数 -- params
    data:data
    })
};
export function xileishan(id) {
    return service({
        url: "/admin/department/"+id,
        method: "delete",
    })
};

////3
export function zhuanyi(params,page = 1) {
    return service({
        url: "/admin/major/page/"+ page ,
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function zhuanyi2(params) {
    return service({
        url: "/admin/major/page/count",
        method: "get",
        // get传递参数 -- params
        params: params
    })
};export function zhuanyijia(data) {
    return service({
        url: "/admin/major",
        method: "post",
        // get传递参数 -- params
        data:data
    })
};
export function zhuanyixq(id) {
    return service({
        url: "/admin/major/"+id ,
        method: "get",
        // get传递参数 -- params
     
    })
};
export function zhuanyixg(data) {
    return service({
        url: "/admin/major/",
        method: "put",
        // get传递参数 -- params
    data:data
    })
};
export function shan3(id) {
    return service({
        url: "/admin/major/"+id,
        method: "delete",
    })
};
////4
export function banjigl(params,page = 1) {
    return service({
        url: "/admin/class/page/"+ page ,
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function banjigl3(params) {
    return service({
        url: "/admin/class/page/count" ,
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function banjigljia(data) {
    return service({
        url: "/admin/class" ,
        method: "post",
        // get传递参数 -- params
       data:data
    })
};
export function banjiglxq(id) {
    return service({
        url: "/admin/class/"+id ,
        method: "get",
        // get传递参数 -- params
      
    })
};
export function banjiglxg(data) {
    return service({
        url: "/admin/class" ,
        method: "put",
        // get传递参数 -- params
       data:data
    })
};
export function shan4(id) {
    return service({
        url: "/admin/class/"+id,
        method: "delete",
    })
};
/////5
export function xsgl(params,page = 1) {
    return service({
        url: "/admin/student/page/"+ page ,
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function xsgl1(params) {
    return service({
        url: "/admin/student/page" ,
        method: "get",
        // get传递参数 -- params
        params: params
    })
}
export function xstjxq(id) {
    return service({
        url: "/admin/student/" +id,
        method: "get",
        // get传递参数 -- params
     
    })
};
export function xstjxg(data) {
    return service({
        url: "/admin/student" ,
        method: "put",
        // get传递参数 -- params
        data:data
    })
};

export function shan5(id) {
    return service({
        url: "/admin/student/"+id,
        method: "delete",
    })
};
/////6
export function jsgl(params,page = 1) {
    return service({
        url: "/admin/teacher/page/"+ page ,
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function jsgl2(params) {
    return service({
        url: "/admin/teacher/page/count",
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function jsjia(data) {
    return service({
        url: "/admin/teacher",
        method: "post",
        // get传递参数 -- params
      data:data
    })
};
export function jiaoshiid(params) {
    return service({
        url: "/admin/teacher/names",
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function jsxq(id) {
    return service({
        url: "/admin/teacher/" +id,
        method: "get",
        // get传递参数 -- params
     
    })
};
export function jsxg(data) {
    return service({
        url: "/admin/teacher" ,
        method: "put",
        // get传递参数 -- params
        data:data
    })
}
export function shan6(id) {
    return service({
        url: "/admin/teacher/"+id,
        method: "delete",
    })
};
/////7
export function kcgl(params,page = 1) {
    return service({
        url: "/admin/course/page/"+ page ,
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function kcgl3(params) {
    return service({
        url: "/admin/course/page/count" ,
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function kctj01(data) {
    return service({
        url: "/admin/course" ,
        method: "post",
        // get传递参数 -- params
       data:data
    })
};
export function kctjxq(id) {
    return service({
        url: "/admin/course/"+id ,
        method: "get",
        // get传递参数 -- params
  
    })
};
export function kctjxg(data) {
    return service({
        url: "/admin/course" ,
        method: "put",
        // get传递参数 -- params
       data:data
    })
};
export function shan7(id) {
    return service({
        url: "/admin/course/"+id,
        method: "delete",
    })
};
//////////8
export function xkgl(params,page = 1) {
    return service({
        url: "/admin/student/course/page/"+ page ,
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function xkgl3(params) {
    return service({
        url: "/admin/student/course/page/count" ,
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function xktj01(data) {
    return service({
        url: "/admin/student/course",
        method: "post",
        // get传递参数 -- params
        data:data
    })
};
export function xkxq(id) {
    return service({
        url: "/admin/student/course/"+id ,
        method: "get",
        // get传递参数 -- params
  
    })
};
export function xkxg(data) {
    return service({
        url: "/admin/student/course" ,
        method: "put",
        // get传递参数 -- params
       data:data
    })
};
export function shan8(id) {
    return service({
        url: "/admin/student/course/"+id,
        method: "delete",
    })
};
/////9
export function glygl(params) {
    return service({
        url: "/admin/admin",
        method: "get",
        // get传递参数 -- params
        params: params
    })
};
export function glytianjia(data) {
    return service({
        url: "/admin/admin",
        method: "post",
        // get传递参数 -- params
         data:data
    })
};
export function glyglxq(id) {
    return service({
        url: "/admin/admin/"+id ,
        method: "get",
        // get传递参数 -- params
  
    })
};
export function glyglxg(data) {
    return service({
        url: "/admin/admin" ,
        method: "put",
        // get传递参数 -- params
       data:data
    })
};

export function shan9(id) {
    return service({
        url: "/admin/admin/"+id,
        method: "delete",
    })
};

///////////////////////////////////////////////////jiaoshi
////授课
export function skcx(data) {
    return service({
        url: "/teacher/course/list" ,
        method: "get",
        // get传递参数 -- params
       data:data
    })
};

////////////////////教师
export function jskb(data) {
    return service({
        url: "/teacher/timetable" ,
        method: "get",
        // get传递参数 -- params
       data:data
    })
};

export function cjlrb(data,page=1) {
    return service({
        url: "/teacher/grade/page/" +page,
        method: "get",
        // get传递参数 -- params
       data:data
    })
};
export function cjlrt(data) {
    return service({
        url: "/teacher/grade/page/count" ,
        method: "get",
        // get传递参数 -- params
       data:data
    })
};
export function cjlrxq(id) {
    return service({
        url: "/teacher/grade/"+id ,
        method: "get",
        // get传递参数 -- params
      
    })
};
export function cjlrdf(data) {
    return service({
        url: "/teacher/grade" ,
        method: "put",
        // get传递参数 -- params
   data:data
    })
};
